<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        {{ fullName }}
        <input type="text" v-model="firstName" @change="cg">
    </div>
<script src="../js/vue.js"></script>
<script>
    let app = new Vue({
        el: "#app",
        data: {
            firstName: 'Foo',
            lastName: 'Bar',
            // fullName: 'Foo Bar'
        },
        // watch: {
        //     firstName: function (val) {
        //         console.log("firstName");
        //         this.fullName = val + ' ' + this.lastName
        //     },
        //     lastName: function (val) {
        //         console.log("lastName");
        //         this.fullName = this.firstName + ' ' + val
        //     }
        // },
        methods: {
            cg(event) {
                console.log(this.firstName, event.target.value);
            }
        },
        computed: {
            fullName: function () {
                return this.firstName + ' ' + this.lastName
            }
        }
    })
</script>
</body>
</html>